<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>easy-chat test</title>
	<link rel="stylesheet" href="css/easy-chat.css">
	<style>
		.isLogin .loginBtn {
			display: none;
		}

		.loginBtn {
			padding: 5px 8px;
			height: 22px;
			line-height: 22px;
			display: block;
			color: #333;
			text-decoration: none;
		}
	</style>
	<script src="js/lib/jquery.min.js"></script>
	<!--[if lt IE 9]>
	<script src="js/lib/json3.js"></script>
	<![endif]-->
</head>
<body>
<div id="userProfile" style="width: 200px;height: 52px;padding:10px;text-align:center;position: fixed;top: 12px;right: 12px;z-index: 1;background: #fff;">
	<a href="php/user.php?act=login" class="loginBtn">登录</a>
</div>

<script src="js/lib/socket.io.js"></script>
<script src="js/lib/iscroll.min.js"></script>
<script src="js/lib/moment.min.js"></script>
<script src="js/lib/jquery.gray.min.js"></script>
<script src="js/lib/audiojs/audio.min.js"></script>
<script src="js/config.js"></script>
<script src="js/easy-chat.js"></script>

<script>
	$(function () {
		$userProfile = $('#userProfile');
		$.get('php/user.php?act=get_user_info', function (resp) {
			if (resp && resp.code === 0) {
				$userProfile.addClass('isLogin');
				var uInfo = resp.my;
				var html = '<div id="userInfoBox">' +
					'<img src="' + uInfo.avatar + '" style="width:32px;height:32px;border-radius:16px;vertical-align: middle;"><span style="margin-left: 1em;margin-right: 1em;">' + uInfo.user_name +
					'</span><a href="php/user.php?act=logout">退出</a>' +
					'</div>';
				$userProfile.append(html);
			} else {
				$userProfile.removeClass('isLogin');
				$('#userInfoBox').remove();
			}
		}, 'json');

		$.easychat({
			url: 'js/easy-chat.tpl',
			user_info_url: 'php/user.php?act=get_user_info'
		});

		$('body').css('min-height', $(window).outerHeight());
	});

</script>
</body>
</html>